String.prototype.cleanup = function () {
	return this.replace(/[^a-zöäüÖÄÜßA-Z0-9 \-_.]/g, '');
};
String.prototype.cleanupNum = function () {
	return this.replace(/[^0-9]/g, '');
};

function getPixelWidth (searchString) {
	return parseInt($(searchString).css('width').slice(0,-2), 10);
}

function getAbsoluteLeftFromRelative (parentSelector, relativeLeft) {
	var parentWidth = functions.getPixelWidth(parentSelector);
	return parentWidth * relativeLeft;
}

function calcRelativeLeft (parentSelector, absoluteLeft) {
	var parentWidth = functions.getPixelWidth(parentSelector);
	return absoluteLeft / parentWidth;
}

function translateIntToColor (v) {
	// translate integers 0 - 1791 to a hex color code
	var u,d;
	switch (Math.floor(v/255)) {
		case 0:
			return '#'+((v<16)?'0':'')+v.toString(16)+'0000';
		case 1:
			u=v-(256*1);
			return '#ff'+((u<16)?'0':'')+u.toString(16)+'00';
		case 2:
			d=255-(v-(256*2));
			return '#'+((d<16)?'0':'')+d.toString(16)+'ff00';
		case 3:
			u=v-(256*3);
			return '#00ff'+((u<16)?'0':'')+u.toString(16);
		case 4:
			d=255-(v-(256*4));
			return '#00' + ((d<16)?'0':'')+d.toString(16) + 'ff';
		case 5:
			u=v-(256*5);
			return '#'+((u<16)?'0':'')+u.toString(16)+'00ff';
		case 6:
			d=255-(v-(256*6));
			return '#ff00'+((d<16)?'0':'')+d.toString(16);
		case 7:
			return '#ffffff';
	}
}

var functions = {
	translateIntToColor: translateIntToColor,
	getPixelWidth: getPixelWidth,
	getAbsoluteLeftFromRelative: getAbsoluteLeftFromRelative,
	calcRelativeLeft: calcRelativeLeft
};